<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace app\home\controller;

use app\home\model\MemberModel;
use cmf\controller\UserBaseController;
use think\Db;


class PassworkController extends UserBaseController
{
    
    public function index(){

        $uinfo= cmf_get_current_user();
        $today_time=strtotime('today');
        $where['operatorid']=$uinfo['id'];
        $where['storeid']=$uinfo['store_id'];
        $where['payStatus']=1;
        $where['ctime'][]=array('lt',time());
        $where['ctime'][]=array('gt',$today_time);
        $order=DB::name('Order')->where($where)->select();
        $total_money=Db::name('Order')->where($where)->sum('totalMoney');//该店铺该商品总营业额
        $actualMoney=Db::name('Order')->where($where)->sum('actualMoney');//该店铺该商品总营业额
        $count=Db::name('Order')->where($where)->count();//该店铺该商品总营业额
        //支付方式
        $payType=Db::name('PayName')->select()->toarray();
        $this->assign('payType',$payType);
        $this->assign('order',$order);
        $this->assign('total_money',$total_money);
        $this->assign('actualMoney',$actualMoney);
        $this->assign('count',$count);
        $this->assign('uinfo',$uinfo);
        return $this->fetch();
    }
    function back(){
        //取消
        return $this->fetch('member/index');
    }
    function passwork(){
        session("user", null);//只有前台用户退出
       return $this->success();
    }
    function cancel(){
        session("user", null);//只有前台用户退出
        $redirect='/user/login/index';
        $this->success('注销成功', $redirect);
        //return redirect();
    }
    public function supply()
    {
//         $uinfo=cmf_get_current_user();
//         $param = $this->request->param();
//         $id=$param['id'];
//         $this->assign("id", $id);
//         $this->assign("uinfo", $uinfo);
        return $this->fetch();
    }
    public function supplyPost(){
        $param = $this->request->param();
        dump($param);exit;
        $data=array(
            'pid'=>$param['pid'],
            'storeid'=>$param['storeid'],
            'operatorid'=>$param['operatorid'],
            'money'=>$param['money'],
            'remark'=>$param['remark'],
            'ctime'=>time(),
        );
        //$actualMoney=Db::name('OperatorStatis')->where(array('id'=>$param['pid']))->field('actualMoney')->find();
        //$money=$actualMoney['actualMoney']+$param['money'];
        //$re=Db::name('OperatorStatis')->where(array('id'=>$param['pid']))->setField('actualMoney',$money);
        $re=Db::name('Supply')->insert($data);
        if($re){
            $this->success("修订成功！");
        }else{
            $this->error("修订失败！");
        }
    }
}
























